import React, { useEffect, useState, useContext } from "react";
import { ThemeContext } from "../components/contextCom"


function UseEffect(props) {
    const [msg, setMsg] = useState("开始了")
    const value = useContext(ThemeContext);
    useEffect(() => {
        console.log(1)
        setTimeout(() => {
            setMsg("过了2秒")
        }, 2000)
    })
    return (
        <div>
            {props.children}
            <div>msg:{msg}</div>
            <div style={{background:value.background}}>
                {value.background} 
                <button onClick={props.handleThemeChange}>修改背景色</button>
                </div>
        </div>
    )
}


export default UseEffect;